<template>
    <div class="edu-page-warp">
        <InnerBreadcrumb v-model="indexKey" :path="breadPath" :showBack="true" />
        <div v-if="indexKey == '0'">
            <condition-card @reset="reset" @search="onSubmit" label-width="110px">
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('label.grade')">
                            <el-date-picker
                                clearable
                                v-model="queryForm.grade"
                                value-format="yyyy"
                                type="year"
                                :placeholder="$t('common.text.all')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.college')">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.faculty"
                                @change="handleChangeFaculty"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.major')">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.profession"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.profession"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('dic.degreeType')">
                            <el-select
                                filterable
                                style="width:100%"
                                clearable
                                v-model="queryForm.degreeType"
                                @change="handleChangeFaculty"
                            >
                                <el-option
                                    v-for="item in options.degreeType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="8">
                        <el-form-item :label="$t('label.formLearning')">
                            <el-select
                                filterable
                                style="width:100%"
                                clearable
                                v-model="queryForm.formLearning"
                            >
                                <el-option
                                    v-for="item in options.formLearning"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="8">
                        <el-form-item label="审核状态">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.approvalStatus"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.approvalStatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请类型">
                            <el-select
                                filterable
                                style="width:100%"
                                clearable
                                v-model="queryForm.permitType"
                            >
                                <el-option
                                    v-for="item in options.permitType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    </el-row>
                    <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item label="申请原因">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.applyReason"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.applyReason"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请开始时间">
                            <el-date-picker
                                v-model="queryForm.applicationStartTime"
                                clearable
                                value-format="yyyy-MM-dd HH:mm:ss"
                                type="datetime"
                                :placeholder="$t('common.text.all')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请结束时间">
                            <el-date-picker
                                v-model="queryForm.applicationEndTime"
                                clearable
                                value-format="yyyy-MM-dd HH:mm:ss"
                                type="datetime"
                                :placeholder="$t('common.text.all')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>
            <el-card shadow="never">
                <div class="edu-page-title">博转硕管理列表</div>
                <el-row>
                    <el-col :span="4">
                        <el-input
                            v-model="queryForm.keyWord"
                            :placeholder="$t('score.failScoreManage.pleaseInt')"
                            @keyup.enter.native="onSubmit"
                            style="width:200px"
                        >
                            <i
                                class="el-icon-search"
                                slot="suffix"
                                style="margin-top:10px;cursor:pointer"
                                @click="onSubmit"
                            ></i>
                        </el-input>
                    </el-col>
                    <el-col :span="8">
                        <div class="empty-box" />
                    </el-col>
                    <el-col :span="12">
                        <div class="float-right">
                            <el-dropdown @command="handleCommand">
                                <el-button>
                                    {{$t("message.export")}}
                                    <i
                                        class="el-icon-arrow-down el-icon--right"
                                    ></i>
                                </el-button>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item command="download">导出申请表</el-dropdown-item>
                                    <el-dropdown-item command="export">导出列表</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                            <el-button
                                type="primary"
                                v-if="!isStudent"
                                @click="handleBatchCheck"
                            >批量审核</el-button>
                            <el-button
                                type="primary"
                                @click="handleApply"
                                v-if="isStudent"
                            >{{$t('message.apply')}}</el-button>
                        </div>
                    </el-col>
                </el-row>
                <edu-table
                    key="students"
                    :data="students"
                    size="mini"
                    style="width:100%"
                    @page-change="handleCurrentChange"
                    :total="queryForm.total_"
                    :pageSize="queryForm.pageSize_"
                    :pageNum="queryForm.pageNum_"
                    :order="false"
                    @selection-change="handleSelectionChange"
                >
                    <el-table-column :label="$t('label.stuCode')" fixed="left" prop="studentId" />
                    <el-table-column :label="$t('label.stuName')" fixed="left" prop="name" />
                    <el-table-column :label="$t('label.grade')" prop="grade" />
                    <el-table-column
                        :label="$t('label.college')"
                        width="120"
                        prop="facultyI18n"
                        show-overflow-tooltip
                    />
                    <el-table-column
                        :label="$t('label.major')"
                        width="120"
                        prop="professionI18n"
                        show-overflow-tooltip
                    />
                    <el-table-column label="申请类型" prop="permitTypeI18n" show-overflow-tooltip />
                    <el-table-column :label="$t('dic.degreeType')" prop="degreeTypeI18n" />
                    <el-table-column :label="$t('label.formLearning')" prop="formLearningI18n" />
                    <el-table-column label="导师" width="140">
                        <template slot-scope="scope">
                            <span
                                v-if="scope.row.teacherId"
                            >{{scope.row.teacherName}}({{scope.row.teacherId}})</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="申请原因"
                        width="120"
                        show-overflow-tooltip
                        prop="applyReasonI18n"
                    />
                    <el-table-column label="申请时间" width="160" show-overflow-tooltip>
                        <template slot-scope="scope">{{moment(scope.row.applicationTime)}}</template>
                    </el-table-column>
                    <el-table-column :label="$t('courseSummary.aduitType')">
                        <template slot-scope="scope">{{getApproveText(scope)}}</template>
                    </el-table-column>
                     <el-table-column label="当前处理人" width="160" show-overflow-tooltip v-if="isStudent">
                        <template slot-scope="scope">
                            <span v-if="scope.row.approvalStatus>=5 && scope.row.reviewerName">
                                {{scope.row.reviewerName}}({{scope.row.reviewer}})</span>
                            <!--导师-->
                            <span
                                v-else-if="scope.row.approvalStatus==4 && scope.row.reviewerName"
                            >{{scope.row.reviewerName}}({{scope.row.reviewer}})</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="当前处理人" width="160" show-overflow-tooltip v-if="!isStudent">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="scope.row.approvalStatus>=5 && scope.row.reviewerName"
                                @click="handleReviewGroup(scope.row.reviewer)"
                            >{{scope.row.reviewerName}}({{scope.row.reviewer}})</el-button>
                            <!--导师-->
                            <span
                                v-else-if="scope.row.approvalStatus==4 && scope.row.reviewerName"
                            >{{scope.row.reviewerName}}({{scope.row.reviewer}})</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :label="$t('message.operating')"
                        fixed="right"
                        :width="oprWidth"
                    >
                        <template slot-scope="scope">
                            <el-button
                                v-if="!isStudent&&scope.row.isApproved==0"
                                type="text"
                                @click="handleCheck(scope)"
                            >{{$t('message.check')}}</el-button>
                            <el-button
                                type="text"
                                @click="handleDetail(scope)"
                            >{{$t('message.detail')}}</el-button>
                            <!--当前为学生时，显示编辑和删除-->
                            <el-button
                                type="text"
                                v-if="scope.row.approvalStatus==0&&isStudent"
                                @click="handleEdit(scope)"
                            >{{$t('message.edit')}}</el-button>
                            <el-button
                                v-if="scope.row.approvalStatus==0&&isStudent"
                                type="text"
                                @click="handleDelete(scope)"
                            >{{$t('message.delete')}}</el-button>
                        </template>
                    </el-table-column>
                </edu-table>
            </el-card>
        </div>
        <div v-if="indexKey == '1'">
            <el-card shadow="never">
                <div v-if="currentStudent">
                    <div class="edu-page-title">学生信息</div>
                    <hr style="margin:15px 0 10px 0" />
                    <el-form
                        label-position="right"
                        label-width="150px"
                        label-suffix="："
                        id="stu-info"
                    >
                        <el-row>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.stuCode')"
                                >{{currentStudent.studentId}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item :label="$t('label.stuName')">{{currentStudent.name}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.college')"
                                >{{currentStudent.facultyI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.major')"
                                >{{currentStudent.professionI18n}}</el-form-item>
                            </el-col>

                            <el-col :span="colSpan">
                                <el-form-item :label="$t('label.grade')">{{currentStudent.grade}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item label="导师">
                                    <span
                                        v-if="currentStudent.teacherId"
                                    >{{currentStudent.teacherName}}({{currentStudent.teacherId}})</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.trainingLevel')"
                                >{{currentStudent.trainingLevelI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item label="申请类型">{{currentStudent.permitTypeI18n}}</el-form-item>
                            </el-col>

                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('dic.degreeType')"
                                >{{currentStudent.degreeTypeI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.formLearning')"
                                >{{currentStudent.formLearningI18n}}</el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <hr style="margin:0 0 15px 0" />
                <!--详情-->
                <div v-if="isRead">
                    <div class="edu-page-title">申请明细</div>
                    <table class="table-detail">
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                        <tr>
                            <td class="label">
                                <span>申请原因：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.applyReasonI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>请示文号：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.pleaseNum}}</span>
                            </td>
                            <td class="label">
                                <span>发文编号：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.issueNum}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士专业：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masProfessionI18n}}({{currentStudent.masProfession}})</span>
                            </td>
                            <td class="label">
                                <span>硕士导师：</span>
                            </td>
                            <td>
                                <span
                                    v-if="currentStudent.masTeacherId"
                                >{{currentStudent.masTeacherName}}({{currentStudent.masTeacherId}})</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士培养层次：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masTrainingLevelI18n}}</span>
                            </td>
                            <td class="label">
                                <span>硕士培养类别：</span>
                            </td>
                            <td>
                                <span
                                >{{currentStudent.masTrainingCategoryI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士学位类型：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.masDegreeTypeI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士年级：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masGrade}}</span>
                            </td>
                            <td class="label">
                                <span>入学季节：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masEnrolSeasonI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>博转硕开始时间：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masStartTime}}</span>
                            </td>
                            <td class="label">
                                <span>硕士阶段最晚结束时间：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masEndTime}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>原因说明：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.reasonDescri}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>申请材料：</span>
                            </td>
                            <td colspan="3">
                                <!-- <div :key="index" v-for="(file,index) in currentStudent.evidence">
                                    <span>
                                        <a
                                            href="#"
                                            @click="handleDownLoad(file)"
                                        >{{getFileName(file.name)}}</a>
                                    </span>
                                </div> -->
                                <PreviewOffice
                                :newFileList="currentStudent.evidence"
                                />
                            </td>
                        </tr>
                    </table>
                </div>
                <div v-else>
                    <div class="edu-page-title">申请明细</div>
                    <el-form label-width="170px" label-suffix="：">
                        <el-row :gutter="20">
                            <el-col :span="8">
                                <el-form-item label="申请原因" :rules="requireRule">
                                    <el-select
                                        v-model="currentStudent.applyReason"
                                        disabled
                                        style="width:100%"
                                    >
                                        <el-option
                                            v-for="item in options.applyReason"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col
                                :span="8"
                                v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"
                            >
                                <el-form-item label="请示文号">
                                    <el-input
                                        v-model="submitForm.pleaseNum"
                                        disabled
                                        style="width:100%"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                        :gutter="20"
                        v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"
                        >
                            <el-col :span="8">
                                <el-form-item label="硕士专业" :rules="requireRule">
                                    <el-select
                                        v-model="submitForm.masProfession"
                                        clearable
                                        filterable
                                        disabled
                                        style="width:100%"
                                    >
                                        <el-option
                                            v-for="item in options.masProfessions"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="硕士导师" :rules="requireRule">
                                    <!-- <el-select
                                        v-model="submitForm.masTeacherId"
                                        clearable
                                        style="width:100%"
                                        disabled
                                    >
                                        <el-option
                                            v-for="item in options.masTeachers"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select> -->
                                    <select-For-Page
                                        v-model="submitForm.masTeacherId"
                                        URL="/api/studentservice/userInfo/studentOrTeacherPageList"
                                        :queryType="1"
                                        :val="submitForm.masTeacherId"
                                        @returnVal="getTeacherCode"
                                        :ifDisabled="true"
                                    ></select-For-Page>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20" v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"> 
                          <el-col :span="8">
                                <el-form-item label="硕士培养层次"  :rules="requireRule">
                                    <el-select
                                        v-model="submitForm.masTrainingLevel"
                                        style="width:100%"
                                        clearable
                                        @change="getGraduateDegree()"
                                        collapse-tags
                                        disabled
                                    >
                                        <el-option
                                            v-for="item in options.trainingLevel"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="硕士培养类别"  :rules="requireRule">
                                    <el-select
                                        v-model="submitForm.masTrainingCategory"
                                        style="width:100%"
                                        clearable
                                        disabled
                                    >
                                        <el-option
                                            v-for="item in options.trainingCategory"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>    
                        </el-row>
                        <el-row :gutter="20" v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"> 
                          <el-col :span="8">
                                <el-form-item label="硕士学位类型"  :rules="requireRule">
                                    <el-select
                                        v-model="submitForm.masDegreeType"
                                        style="width:100%"
                                        @change="getGraduateDegree()"
                                        clearable
                                        disabled
                                    >
                                        <el-option
                                            v-for="item in options.degreeType"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>     
                        <el-row
                            :gutter="20"
                            v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"
                        >
                            <el-col :span="8">
                                <el-form-item label="硕士年级" :rules="requireRule">
                                    <el-date-picker
                                        clearable
                                        v-model="submitForm.masGrade"
                                        value-format="yyyy"
                                        type="year"
                                        :placeholder="$t('message.plzSelect')"
                                        style="width: 100%"
                                        disabled
                                    />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="硕士入学季节" :rules="requireRule">
                                    <el-select
                                        v-model="submitForm.masEnrolSeason"
                                        clearable
                                        style="width:100%"
                                        disabled
                                    >
                                        <el-option
                                            v-for="item in options.enrolSeason"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            :gutter="20"
                            v-if="currentApproveStatus==status.KEEP_DEAL_APPROVE||currentApproveStatus==status.MANAGE_APPROVE"
                        >
                            <el-col :span="8">
                                <el-form-item label="博转硕开始时间" :rules="requireRule">
                                    <el-input
                                        v-model="submitForm.masStartTime"
                                        style="width: 100%"
                                        disabled
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="硕士阶段最晚结束时间" :rules="requireRule">
                                    <el-input
                                        v-model="submitForm.masEndTime"
                                        style="width: 100%"
                                        disabled
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20">
                            <el-col :span="16">
                                <el-form-item label="原因说明" :rules="requireRule">
                                    <el-input
                                        type="textarea"
                                        rows="4"
                                        disabled
                                        style="width:100%"
                                        v-model="currentStudent.reasonDescri"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="20">
                            <el-col :span="8">
                                <el-form-item label="申请材料" :rules="requireRule">
                                    <!-- <div
                                        :key="index"
                                        v-for="(file,index) in currentStudent.evidence"
                                    >
                                        <a
                                            href="#"
                                            @click="handleDownLoad(file)"
                                        >{{getFileName(file.name)}}</a>
                                    </div> -->
                                    <PreviewOffice
                                    :newFileList="currentStudent.evidence"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </el-card>
            <!--审核提交-->
            <el-card shadow="never" v-if="!isRead">
                <div class="edu-page-title">审核</div>
                <el-form
                    label-width="170px"
                    label-suffix="："
                    ref="submitForm"
                    :model="submitForm"
                    :rules="submitRules"
                >
                    <!--请示文号在导师状态和留办状态不显示-->
                    <el-row
                        :gutter="20"
                        v-if="currentApproveStatus!=status.TEACHER_APPROVE&&currentApproveStatus!=status.KEEP_DEAL_APPROVE"
                    >
                        <el-col :span="8" v-if="currentApproveStatus!=status.MANAGE_APPROVE">
                            <el-form-item label="请示文号" prop="pleaseNum">
                                <el-input
                                    v-model="submitForm.pleaseNum"
                                    style="width:100%"
                                    maxlength="30"
                                    :disabled="currentApproveStatus==status.CULTURE_APPROVE"
                                />
                            </el-form-item>
                        </el-col>
                        <!--管理处显示-->
                        <el-col :span="8" v-if="currentApproveStatus==status.MANAGE_APPROVE">
                            <el-form-item label="发文编号" prop="issueNum">
                                <el-input
                                    v-model="submitForm.issueNum"
                                    style="width:100%"
                                    maxlength="30"
                                />
                            </el-form-item>
                        </el-col>
                        
                    </el-row>
                    <!--留办和管理处不显示-->
                    <!-- v-if="currentApproveStatus!=status.KEEP_DEAL_APPROVE&&currentApproveStatus!=status.MANAGE_APPROVE" -->
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <!-- 培养层次 -->
                            <el-form-item label="硕士培养层次" prop="masTrainingLevel">
                                <el-select
                                    v-model="submitForm.masTrainingLevel"
                                    style="width:100%"
                                    clearable
                                    @change="getGraduateDegree()"
                                    collapse-tags
                                    :disabled="Number(currentApproveStatus) < 5"
                                >
                                    <el-option
                                        v-for="item in options.trainingLevel"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <!-- 培养类别 -->
                            <el-form-item label="硕士培养类别" prop="masTrainingCategory">
                                <el-select
                                    v-model="submitForm.masTrainingCategory"
                                    style="width:100%"
                                    clearable
                                    :disabled="Number(currentApproveStatus) < 5"
                                >
                                    <el-option
                                        v-for="item in options.trainingCategory"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <!-- 学位类型 -->
                            <el-form-item label="硕士学位类型" prop="masDegreeType">
                                <el-select
                                    v-model="submitForm.masDegreeType"
                                    style="width:100%"
                                    @change="getGraduateDegree()"
                                    clearable
                                    :disabled="Number(currentApproveStatus) < 5"
                                >
                                    <el-option
                                        v-for="item in options.degreeType"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row
                        :gutter="20"
                        
                    >
                        <!--学院和培养处不可修改-->
                        <el-col :span="8" v-if="currentApproveStatus==status.TEACHER_APPROVE">
                            <el-form-item label="申请原因" prop="applyReason">
                                <el-select
                                    v-model="submitForm.applyReason"
                                    clearable
                                    style="width:100%"
                                >
                                    <el-option
                                        v-for="item in options.applyReason"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="硕士专业" prop="masProfession">
                                <el-select
                                    v-model="submitForm.masProfession"
                                    clearable
                                    filterable
                                    style="width:100%"
                                    :disabled="Number(currentApproveStatus) < 5"
                                >
                                    <el-option
                                        v-for="item in options.masProfessions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="硕士导师" prop="masTeacherId">
                                <!-- <el-select
                                    v-model="submitForm.masTeacherId"
                                    clearable
                                    filterable
                                    style="width:100%"
                                >
                                    <el-option
                                        v-for="item in options.masTeachers"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select> -->
                                <select-For-Page
                                    v-model="submitForm.masTeacherId"
                                    URL="/api/studentservice/userInfo/studentOrTeacherPageList"
                                    :queryType="1"
                                    :val="submitForm.masTeacherId"
                                    @returnVal="getTeacherCode"
                                    :ifDisabled='Number(currentApproveStatus) < 5'
                                ></select-For-Page>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <!--留办和管理处不显示-->
                    <!-- v-if="currentApproveStatus!=status.KEEP_DEAL_APPROVE&&currentApproveStatus!=status.MANAGE_APPROVE" -->
                    <el-row
                        :gutter="20"
                        v-if="currentApproveStatus == 8"
                    >
                        <el-col :span="8">
                            <el-form-item label="硕士年级" prop="masGrade">
                                <el-date-picker
                                    clearable
                                    v-model="submitForm.masGrade"
                                    value-format="yyyy"
                                    type="year"
                                    :placeholder="$t('message.plzSelect')"
                                    style="width: 100%"
                                    @change="handleTime"
                                />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="硕士入学季节" prop="masEnrolSeason">
                                <el-select
                                    v-model="submitForm.masEnrolSeason"
                                    clearable
                                    style="width:100%"
                                    @change="handleTime"
                                >
                                    <el-option
                                        v-for="item in options.enrolSeason"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!--留办和管理处不显示-->
                    <!-- v-if="currentApproveStatus!=status.KEEP_DEAL_APPROVE&&currentApproveStatus!=status.MANAGE_APPROVE" -->
                    <el-row
                        :gutter="20"
                        v-if="currentApproveStatus == 8"
                    >
                        <el-col :span="8">
                            <el-form-item label="博转硕开始时间" prop="masStartTime">
                                <el-input
                                    v-model="submitForm.masStartTime"
                                    style="width: 100%"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="硕士阶段最晚结束时间" prop="masEndTime">
                                <el-input
                                    v-model="submitForm.masEndTime"
                                    style="width: 100%"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="24">
                            <el-form-item label="审批意见" prop="suggestion">
                                <el-input
                                    type="textarea"
                                    rows="4"
                                    v-model="submitForm.suggestion"
                                    style="width:100%"
                                    maxlength="400"
                                />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!--导师审核显示-->
                    <el-row
                        :gutter="20"
                        v-if="currentStudent.approvalStatus==status.TEACHER_APPROVE"
                        class="waring-msg"
                    >
                        <p>请注意：研究生博士阶段已使用的导师资助经费按实际情况处理，未使用的资助经费暂时作为结余经费；</p>
                        <p>研究生硕士阶段最长学习年限为2.5年，导师资助经费为3000元/人，助学金发放方式同普通硕士研究生。</p>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="24" style="text-align:right">
                            <el-button type="danger" @click="handleReject">{{$t('message.reject')}}</el-button>
                            <el-button type="primary" @click="handlePass">{{$t('message.pass')}}</el-button>
                        </el-col>
                    </el-row>
                </el-form>
            </el-card>

            <el-card shadow="never" v-if="currentStudent&&currentStudent.workflowNo">
                <div class="edu-page-title">审批进度</div>
                <edu-table
                    key="prograss"
                    :pagination="false"
                    style="margin-top:10px"
                    :selection="false"
                    :data="historys"
                    :order="false"
                >
                    <el-table-column :label="$t('message.order')" prop="order_" width="50" />
                    <el-table-column :label="$t('message.time')" prop="approvalTime">
                        <template slot-scope="scope">{{ moment(scope.row.approvalTime)}}</template>
                    </el-table-column>
                    <el-table-column label="审批人">
                        <template
                            slot-scope="scope"
                        >{{scope.row.reviewerName}}({{scope.row.reviewer}})</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.operation')" prop="processOperat" />
                    <el-table-column label="节点" prop="processNodes" />
                    <el-table-column label="说明" prop="reasonDescri" show-overflow-tooltip />
                </edu-table>
            </el-card>
        </div>
        <!--申请/编辑，学生信息与申请明细在不同的el-card中-->
        <div v-if="indexKey=='2'">
            <el-card shadow="never" v-if="currentStudent">
                <div class="edu-page-title">学生信息</div>
                <hr style="margin:15px 0 10px 0" />
                <el-form label-position="right" label-width="150px" label-suffix="：" id="stu-info">
                    <el-row>
                        <el-col :span="colSpan">
                            <el-form-item :label="$t('label.stuCode')">{{currentStudent.studentId}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item :label="$t('label.stuName')">{{currentStudent.name}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item
                                :label="$t('label.college')"
                            >{{currentStudent.facultyI18n}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item
                                :label="$t('label.major')"
                            >{{currentStudent.professionI18n}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item :label="$t('label.grade')">{{currentStudent.grade}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item label="导师">
                                <span
                                    v-if="currentStudent.teacherId"
                                >{{currentStudent.teacherName}}({{currentStudent.teacherId}})</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item
                                :label="$t('label.trainingLevel')"
                            >{{currentStudent.trainingLevelI18n}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item label="申请类型">{{currentStudent.permitTypeI18n}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item
                                :label="$t('dic.degreeType')"
                            >{{currentStudent.degreeTypeI18n}}</el-form-item>
                        </el-col>
                        <el-col :span="colSpan">
                            <el-form-item
                                :label="$t('label.formLearning')"
                            >{{currentStudent.formLearningI18n}}</el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </el-card>
            <!--学生新增或编辑表单-->
            <apply-form
                ref="submitForm"
                :options="options"
                @close="handleReturn"
                @success="handleSave"
                :show-save-btn="true"
                :students="[currentStudent]"
                :edit-form="editForm"
                :mas-profession="currentStudent.profession"
                :teacherId="currentStudent.teacherId"
            />
        </div>
        <div id="batch-dialog">
            <edu-dialog
                title="批量审核"
                ref="batchApproveDialog"
                width="500px"
                @close="handleBatchClose"
            >
                <el-form
                    ref="batchForm"
                    :model="batchForm"
                    :rules="batchRules"
                    label-suffix="："
                    label-width="80px"
                >
                    <el-row v-if="batchApproveStatus==status.COLLEGE_APPROVE">
                        <el-col :span="24">
                            <el-form-item prop="pleaseNum" label="请示文号">
                                <el-input
                                    v-model="batchForm.pleaseNum"
                                    placeholder="请输入"
                                    style="width:50%"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row v-if="batchApproveStatus==status.MANAGE_APPROVE">
                        <el-col :span="24">
                            <el-form-item prop="issueNum" label="发文编号">
                                <el-input
                                    v-model="batchForm.issueNum"
                                    placeholder="请输入"
                                    style="width:50%"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item prop="suggestion" label="审批意见">
                                <el-input
                                    placeholder="请输入"
                                    type="textarea"
                                    v-model="batchForm.suggestion"
                                    rows="4"
                                    maxlength="400"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <template slot="buttons">
                    <el-button @click="handleBatchCancel">{{$t('message.cancel')}}</el-button>
                    <el-button @click="handleBatchReject" type="danger">{{$t('message.reject')}}</el-button>
                    <el-button @click="handleBatchPass" type="primary">{{$t('message.pass')}}</el-button>
                </template>
            </edu-dialog>
        </div>
        <edu-dialog
            title="组内用户明细"
            ref="groupUsers"
            width="800px"
            @close="handleGroupUsersClose"
            :showFooter="false"
        >
            <edu-table
                key="users"
                :data="users"
                size="mini"
                style="width:100%"
                @page-change="handleUserCurrentChange"
                :total="usersQueryForm.total_"
                :pageSize="usersQueryForm.pageSize_"
                :pageNum="usersQueryForm.pageNum_"
                :selection="false"
            >
                <el-table-column label="账号" prop="studentId" width="100"></el-table-column>
                <el-table-column label="用户名" prop="name" width="100"></el-table-column>
                <el-table-column label="联系电话" prop="phoneNumber" show-overflow-tooltip></el-table-column>
                <el-table-column label="联系邮箱" prop="email" show-overflow-tooltip></el-table-column>
                <el-table-column label="类型" width="80">
                    <template slot-scope="scope">{{getUserType(scope.row.userType)}}</template>
                </el-table-column>
            </edu-table>
        </edu-dialog>
    </div>
</template>
<script>
import { queryDic } from "common/src/api/dictionary";
import {
    getmanageList,
    getStudentInfo,
    getMasTime,
    getStuTeas,
    deleteManage,
    approvalHistory,
    exportDocToMasterDocxZip,
    exportManageList,
    addmanage,
    reviewerUpdateManage,
    getGraduateDegreeByColleges
} from "common/src/api/culture/change";
import { downloadfile } from "common/src/api/upload";
import { approvalThrough, approvalReject } from "common/src/api/approval";
import { throughBatch, rejectBatch } from "common/src/api/studentRegister";
import { getUserInfoListByGroupId } from "common/src/api/user";
import stu from 'common/src/api/studentinfo'
import ApplyForm from "./ApplyForm";
import selectForPage from 'common/src/components/common/selectForPage'
import PreviewOffice from "common/src/components/common/PreviewOffice.vue"
import mixin from 'common/src/mixins/index';
export default {
    name: "DoctorToMasterManage",
    mixins: [mixin],
    components: {
        'select-For-Page': selectForPage,
        ApplyForm,
        PreviewOffice
    },
    data: function() {
        return {
            status: {
                TEACHER_APPROVE: 4,
                COLLEGE_APPROVE: 5,
                KEEP_DEAL_APPROVE: 6,
                CULTURE_APPROVE: 7,
                MANAGE_APPROVE: 8
            },
            currentApproveStatus: 0,
            queryForm: {
                grade: null,
                faculty: [],
                profession: [],
                permitType: null,
                degreeType: null,
                formLearning: null,
                applyReason: [],
                approvalStatus: [],
                applicationStartTime: null,
                applicationEndTime: null,
                keyWord: null,
                pageSize_: 20,
                pageNum_: 1,
                total_: 0
            },
            options: {
                faculty: [],
                profession: [],
                degreeType: [],
                trainingLevel: [],
                trainingCategory: [],
                formLearning: [],
                applyReason: [],
                permitType: [],
                approvalStatus: [],
                enrolSeason: [],
                masProfessions: [],
                masTeachers: []
            },
            students: null,
            selectStudents: [],
            currentStudent: null,
            historys: null,
            editForm: null,
            indexKey: 0,
            breadPath: {
                label: "博转硕",
                key: "0",
                children: [
                    {
                        key: "1",
                        label: ""
                    },
                    {
                        key: "2",
                        label: ""
                    }
                ]
            },
            applyDetails: {
                applyReason: null,
                reasonDescri: null
            },
            isRead: false,
            isStudent: false,
            oprWidth: 60,
            submitForm: {
                issueNum: null,
                masTrainingLevel: "4", //培养层次
                masTrainingCategory: '3', //培养类别
                masDegreeType: '', //学位类型
                pleaseNum: null,
                applyReason: null,
                masProfession: null,
                masTeacherId: null,
                masGrade: null,
                masEnrolSeason: null,
                masStartTime: null,
                masEndTime: null,
                suggestion: null
            },
            submitRules: {
                applyReason: {
                    required: true,
                    message: "必须选择申请原因",
                    trigger: "change"
                },
                masProfession: {
                    required: true,
                    message: "必须选择硕士专业",
                    trigger: "change"
                },
                masTrainingLevel: {
                    required: true,
                    message: "必须选择培养层次",
                    trigger: "change"
                },
                masTrainingCategory: {
                    required: true,
                    message: "必须选择培养类别",
                    trigger: "change"
                },
                masDegreeType: {
                    required: true,
                    message: "必须选择学位类型",
                    trigger: "change"
                },
                masTeacherId: {
                    required: true,
                    message: "必须选择硕士导师",
                    trigger: "change"
                },
                masGrade: {
                    required: true,
                    message: "必须选择硕士年级",
                    trigger: "change"
                },
                masEnrolSeason: {
                    required: true,
                    message: "必须选择入学季节",
                    trigger: "change"
                },
                masStartTime: {
                    required: true,
                    message: "必须选择硕士阶段开始时间",
                    trigger: "change"
                },
                masEndTime: {
                    required: true,
                    message: "必须选择硕士阶段结束时间",
                    trigger: "change"
                },
                pleaseNum: {
                    validator: this.validatePleaseNum,
                    required: false,
                    trigger: "change"
                },
                issueNum: {
                    required: false,
                    validator: this.validateIssueNum,
                    trigger: "change"
                },
                suggestion: {
                    validator: this.validateSuggestion,
                    trigger: "change"
                }
            },
            batchForm: {
                pleaseNum: null,
                issueNum: null,
                suggestion: null
            },
            batchRules: {
                pleaseNum: {
                    validator: this.validateBatchPleaseNum,
                    trigger: "change"
                },
                issueNum: {
                    validator: this.validateBatchIssueNum,
                    trigger: "change"
                },
                suggestion: {
                    validator: this.validateBatchSuggestion,
                    trigger: "change"
                }
            },
            isBatchReject: false,
            batchApproveStatus: null,
            users: null,
            usersQueryForm: {
                groupId: null,
                pageSize_: 20,
                pageNum_: 1,
                total_: 0
            }
        };
    },
    mounted() {
        this.init();
        let user = this.global.mockUser || this.global.user;
        if (user.type == "2") {
            this.isStudent = true;
        }
    },
    computed: {
        requireRule() {
            return {
                required: true,
                message: "",
                trigger: "change"
            };
        },
        colSpan() {
            if (this.currentStudent == null) {
                return 6;
            }
            if (
                this.currentStudent.facultyI18n &&
                this.currentStudent.facultyI18n.length >= 8
            ) {
                return 8;
            }
            if (
                this.currentStudent.professionI18n &&
                this.currentStudent.professionI18n.length >= 8
            ) {
                return 8;
            }
            return 6;
        }
    },
    methods: {
        // 获取所属学院、姓名
        getTeacherCode(val) {
            if (val) {
                this.submitForm.masTeacherId = val
                 
            } else {
                this.submitForm.masTeacherId = ''
            }
        },
        init() {
            this.options.approvalStatus.push({
                label: "草稿",
                value: "0"
            });
            this.options.approvalStatus.push({
                label: "审核中",
                value: "1"
            });
            this.options.approvalStatus.push({
                label: "驳回",
                value: "2"
            });
            this.options.approvalStatus.push({
                label: "通过",
                value: "3"
            });
            this.options.approvalStatus.push({
                label: "导师审核",
                value: "4"
            });
            this.options.approvalStatus.push({
                label: "学院审核",
                value: "5"
            });
            this.options.approvalStatus.push({
                label: "留办审核",
                value: "6"
            });
            this.options.approvalStatus.push({
                label: "培养处审核",
                value: "7"
            });
            this.options.approvalStatus.push({
                label: "管理处审核",
                value: "8"
            });
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: [
                    "X_YX",
                    "X_PYCC",
                    "X_PYLB",
                    "X_XWLX",
                    "X_XXXS",
                    "K_SQYY",
                    "K_YDSQLX",
                    "X_RXJJ"
                ]
            };
            queryDic(data).then(res => {
                if (res.code === 200) {
                    this.fill("faculty", res.data.X_YX);
                    this.fill("degreeType", res.data.X_XWLX);
                    this.fill("trainingLevel", res.data.X_PYCC);
                    this.fill("trainingCategory", res.data.X_PYLB);
                    this.fill("formLearning", res.data.X_XXXS);
                    this.fill("applyReason", res.data.K_SQYY);
                    this.fill("permitType", res.data.K_YDSQLX);
                    this.fill("enrolSeason", res.data.X_RXJJ);
                }
            });
             
            getGraduateDegreeByColleges({}).then(res => {
                if (res.code == 200) {
                    let language = this.$store.getters.language || "cn";
                    this.options.masProfessions = res.data.map(row => {
                        return {
                            label:
                                (language == "cn" ? row.nameCN : row.nameEn) +
                                " (" +
                                row.code +
                                ")",
                            value: row.code
                        };
                    });
                }
            });
            getStuTeas().then(res => {
                if (res.code == 200) {
                    for (let key in res.data) {
                        this.options.masTeachers.push({
                            label: res.data[key] + "(" + key + ")",
                            value: key
                        });
                    }
                }
            });
            this.onSubmit();
        },
        fill(type, data) {
            for (const key in data) {
                this.options[type].push({
                    value: key,
                    label: data[key]
                });
            }
        },
        reset() {
            this.queryForm.grade = null;
            this.queryForm.faculty = [];
            this.queryForm.profession = [];
            this.queryForm.permitType = null;
            this.queryForm.degreeType = null;
            
            this.queryForm.formLearning = null;
            this.queryForm.applyReason = [];
            this.queryForm.approvalStatus = [];
            this.queryForm.applicationStartTime = null;
            this.queryForm.applicationEndTime = null;
            this.queryForm.keyWord = null;
            this.options.profession.length = 0;
            this.onSubmit();
        },
        getGraduateDegree() {
            if(this.currentStudent && this.currentStudent.faculty) {
                this.submitForm.masProfession = ''
                let parm = {
                        trainingLevel: this.submitForm.masTrainingLevel,
                        facultys: [this.currentStudent.faculty],
                        types: [this.submitForm.masDegreeType]
                    }
                    getGraduateDegreeByColleges(parm).then(resT => {
                    if (resT.code == 200) {
                        let language = this.$store.getters.language || "cn";
                        this.options.masProfessions = resT.data.map(row => {
                            return {
                                label:
                                    (language == "cn" ? row.nameCN : row.nameEn) +
                                    " (" +
                                    row.code +
                                    ")",
                                value: row.code
                            };
                        });
                    }
                });
            } else {
                return false
            }
        },
        onSubmit(isFirstPage = true) {
            if (isFirstPage) {
                this.queryForm.pageNum_ = 1;
            }
            let params = _.cloneDeep(this.queryForm);
            params.faculty =
                params.faculty.length > 0 ? params.faculty.join(",") : null;
            params.profession =
                params.profession.length > 0
                    ? params.profession.join(",")
                    : null;
            params.applyReason =
                params.applyReason.length > 0
                    ? params.applyReason.join(",")
                    : null;
            params.approvalStatus =
                params.approvalStatus.length > 0
                    ? params.approvalStatus.join(",")
                    : null;
            getmanageList(params).then(res => {
                if (res.code == 200) {
                    this.oprWidth = 60;
                    this.students = res.data.list;
                    this.queryForm.total_ = res.data.total_;
                    //当前操作为学生，且存在草稿状态
                    if (
                        this.isStudent &&
                        res.data.list.some(r => r.approvalStatus == 0)
                    ) {
                        this.oprWidth = 130;
                    }
                    //当前不为学生，且存在审核
                    if (
                        !this.isStudent &&
                        res.data.list.some(r => r.isApproved == 0)
                    ) {
                        this.oprWidth = 90;
                    }
                }
            });
        },
        handleCurrentChange(val) {
            this.queryForm.pageSize_ = val.pageSize;
            this.queryForm.pageNum_ = val.pageNum;
            this.onSubmit(false);
        },
        handleApply() {
            let user = this.global.mockUser || this.global.user;
            let studentId = user.uid;
            getStudentInfo(studentId).then(res => {
                if (res.code == 200 && res.data.length > 0) {
                    this.currentStudent = res.data[0];
                    this.editForm = null;
                    this.indexKey = "2";
                    this.breadPath.children[1].label = this.$t("message.apply");
                }
            });
        },
        //打开批量申请对话框
        handleBatchCheck() {
            if (this.selectStudents.length == 0) {
                this.$message({
                    type: "warning",
                    message: "请选择需要审批的申请"
                });
                return;
            }
            if (!this.selectStudents.every(s => s.isApproved == 0)) {
                this.$message({
                    type: "warning",
                    message: "选中学生必须都是待审核状态"
                });
                return;
            }
            if (
                !this.selectStudents.every(
                    s =>
                        s.approvalStatus ==
                        this.selectStudents[0].approvalStatus
                )
            ) {
                this.$message({
                    type: "warning",
                    message: "选中学生审核状态不一致，无法批量审批"
                });
                return;
            }
            this.batchApproveStatus = this.selectStudents[0].approvalStatus;
            this.$refs.batchApproveDialog.open();
            if (this.$refs.batchForm) {
                this.$refs.batchForm.clearValidate();
            }
        },
        handleBatchClose() {
            this.batchForm.pleaseNum = null;
            this.batchForm.issueNum = null;
            this.batchForm.suggestion = null;
        },
        handleCheck(scope) {
            this.currentApproveStatus = scope.row.approvalStatus;
            this.isRead = false;
            this.currentStudent = _.cloneDeep(scope.row);
            if(scope.row.evidence && scope.row.evidence.length > 0) {
                if((scope.row.evidence.substring(0,1)).toString() === '[') {
                this.currentStudent.evidence = JSON.parse(scope.row.evidence)
                } else {
                let filesList = []
                let evidList = scope.row.evidence.split(",")
                evidList.map(files=> {
                    filesList.push(
                    {
                        name: files,
                        url: files
                    }
                    )
                })
                this.currentStudent.evidence = filesList
                }
            }
            this.indexKey = "1";
            this.breadPath.children[0].label = this.$t("message.check");
            //初始化审核表单
            Object.keys(this.submitForm).forEach(key => {
                this.submitForm[key] = null;
                if (this.currentStudent.hasOwnProperty(key)) {
                    this.submitForm[key] =
                        typeof this.currentStudent[key] === "number"
                            ? this.currentStudent[key].toString()
                            : this.currentStudent[key];
                }
            });
            approvalHistory(
                this.currentStudent.workflowNo,
                this.currentStudent.submissionType
            ).then(res => {
                if (res.code == 200) {
                    res.data.forEach((row, index) => {
                        row.order_ = index + 1;
                        if (row.reasonDescri == "null") {
                            row.reasonDescri = null;
                        }
                          
                    });
                    this.historys = res.data;
                     
                }
            });
            this.submitForm.masDegreeType = this.currentStudent.degreeType;
            let parm = {
                trainingLevel: this.submitForm.masTrainingLevel,
                facultys: [scope.row.faculty],
                types: [this.submitForm.masDegreeType]
            }
            getGraduateDegreeByColleges(parm).then(res => {
                if (res.code == 200) {
                    let language = this.$store.getters.language || "cn";
                    this.options.masProfessions = res.data.map(row => {
                        return {
                            label:
                                (language == "cn" ? row.nameCN : row.nameEn) +
                                " (" +
                                row.code +
                                ")",
                            value: row.code
                        };
                    });
                }
            });
        },
        handleDetail(scope) {
            this.isRead = true;
            this.currentStudent = _.cloneDeep(scope.row);
            if(scope.row.evidence && scope.row.evidence.length > 0) {
                if((scope.row.evidence.substring(0,1)).toString() === '[') {
                this.currentStudent.evidence = JSON.parse(scope.row.evidence)
                } else {
                let filesList = []
                let evidList = scope.row.evidence.split(",")
                evidList.map(files=> {
                    filesList.push(
                    {
                        name: files,
                        url: files
                    }
                    )
                })
                this.currentStudent.evidence = filesList
                }
            }
            this.indexKey = "1";
            this.breadPath.children[0].label = this.$t("message.detail");
            if (this.currentStudent.workflowNo) {
                approvalHistory(
                    this.currentStudent.workflowNo,
                    this.currentStudent.submissionType
                ).then(res => {
                    if (res.code == 200) {
                        res.data.forEach((row, index) => {
                            row.order_ = index + 1;
                            if (row.reasonDescri == "null") {
                                row.reasonDescri = null;
                            }
                        });
                        this.historys = res.data;
                    }
                });
            }
        },
        handleEdit(scope) {
            this.isRead = false;
            this.currentStudent = scope.row;
            this.editForm = scope.row;
            this.indexKey = "2";
            this.breadPath.children[1].label = this.$t("message.edit");
        },
        handleDelete(scope) {
            this.$delConfirm().then(() => {
                deleteManage(scope.row.id).then(res => {
                    if (res.code == 200) {
                        this.$message({
                            type: "success",
                            message: this.$t("message.deleteSuccess")
                        });
                        this.onSubmit();
                    }
                });
            });
        },
        //处理批量取消
        handleBatchCancel() {
            this.$refs.batchApproveDialog.close();
        },
        //处理批量拒绝
        handleBatchReject() {
            this.isBatchReject = true;
            this.handleBatchWorkflow("批量审批驳回", rejectBatch);
        },
        //处理批量通过
        handleBatchPass() {
            this.isBatchReject = false;
            this.handleBatchWorkflow("批量审批通过", throughBatch);
        },
        handleBatchWorkflow(msg, method) {
            this.$refs.batchForm.validate(valid => {
                if (!valid) {
                    return;
                }
                let fn = () => {
                    let data = this.selectStudents.map(r => {
                        return {
                            no: r.workflowNo,
                            content: this.batchForm.suggestion
                        };
                    });
                    method(data).then(res => {
                        if (res.code == 200) {
                            this.$message({
                                type: "success",
                                message: msg
                            });
                            this.$refs.batchApproveDialog.close();
                            this.onSubmit();
                        }
                    });
                };
                //驳回直接更新流程
                if (this.isBatchReject) {
                    fn();
                    return;
                }
                //文号或编号无修改，直接更新流程；文号或编号有修改，先修改再更新流程
                if (
                    this.batchForm.pleaseNum != null ||
                    this.batchForm.issueNum != null
                ) {
                    let params = {
                        approvalMethod: 2,
                        ids: this.selectStudents.map(s => s.id).join(","),
                        pleaseNum: this.batchForm.pleaseNum,
                        issueNum: this.batchForm.issueNum
                    };
                    reviewerUpdateManage(params).then(res => {
                        if (res.code == 200) {
                            fn();
                        }
                    });
                } else {
                    fn();
                }
            });
        },
        handleChangeFaculty() {
            this.options.profession = [];
            this.queryForm.profession = [];
            if (this.queryForm.faculty.length == 0) {
                return;
            }
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_ZY"],
                filter: {
                    prefix: this.queryForm.faculty,
                    specilaCode: "XY2ZY",
                    grade: null,
                    facultys: this.queryForm.faculty,
                    degreeType: this.queryForm.degreeType
                        ? [this.queryForm.degreeType]
                        : []
                }
            };
            queryDic(data).then(res => {
                if (res.code === 200) this.fill("profession", res.data.G_ZY);
            });
        },
        handleReturn() {
            this.indexKey = "0";
        },
        handleTime() {
            if (
                this.submitForm.masGrade != null &&
                this.submitForm.masGrade != "" &&
                this.submitForm.masEnrolSeason != null &&
                this.submitForm.masEnrolSeason != ""
            ) {
                getMasTime({
                    masGrade: this.submitForm.masGrade,
                    masEnrolSeason: this.submitForm.masEnrolSeason
                }).then(res => {
                    if (res.code == 200) {
                        this.submitForm.masStartTime = res.data.masStartTime;
                        this.submitForm.masEndTime = res.data.masEndTime;
                    }
                });
            } else {
                this.submitForm.masStartTime = null;
                this.submitForm.masEndTime = null;
            }
        },
        handleSave() {
            this.indexKey = "0";
            this.onSubmit();
        },
        handleReject() {
            this.isReject = true;
            this.handleSingleWorkflow("审批驳回", approvalReject);
        },
        handlePass() {
            this.isReject = false;
            this.handleSingleWorkflow("审批通过", approvalThrough);
        },
        handleSingleWorkflow(msg, method) {
            this.$refs.submitForm.validate(valid => {
                if (!valid) {
                    return;
                }
                let fn = () => {
                    method({
                        no: this.currentStudent.workflowNo,
                        content: this.submitForm.suggestion,
                        approveAttachment: []
                    }).then(res => {
                        if (res.code == 200) {
                            this.$message({
                                type: "success",
                                message: msg
                            });
                            this.onSubmit();
                            this.indexKey = "0";
                        }
                    });
                };
                if (this.isReject) {
                    fn();
                    return;
                }
                let params = _.cloneDeep(this.submitForm);
                params.id = this.currentStudent.id;
                params.reasonDescri = this.currentStudent.reasonDescri;
                params.evidences =  JSON.stringify(this.currentStudent.evidence);
                params.approvalMethod = 1; //单个审批
                reviewerUpdateManage(params).then(res => {
                    if (res.code == 200) {
                        fn();
                    }
                });
            });
        },
        //处理下载
        handleDownLoad(file) {
            // downloadfile(file);
            let url = '/api/commonservice/obsfile/downloadfile?objectkey=' + file.url  
            stu.downTemplate(file.name, url);
        },
        //处理导出申请表与导出
        handleCommand(command) {
            if (command == "download") {
                let flg = false;
                // console.log(this.students, 'this.queryForm');
                if (this.selectStudents.length > 0) {
                    // console.log(this.selectStudents, 'this.selectStudents');
                    let ids = [];
                    // let flg = false;
                    // ids
                    // 导师审核未完成，无法导出博转硕申请表
                    this.selectStudents.forEach(el => {
                        ids.push(el.id);
                        if (el.approvalStatus === '0' || el.approvalStatus === '4') {
                            flg = true;
                            return this.$message('导师审核未完成，无法导出博转硕申请表');
                        }
                    });
                    if (!flg) {

                        this.queryForm.ids = ids.join();
                        window.open(exportDocToMasterDocxZip(this.queryForm));
                        this.queryForm.ids = null;
                    }
                } else {

                    this.students.forEach(el => {
                        if (el.approvalStatus === '0' || el.approvalStatus === '4') {
                            flg = true;
                            return this.$message('导师审核未完成，无法导出博转硕申请表');
                        }
                    });
                    if (!flg) {

                        this.queryForm.ids = null;
                        window.open(exportDocToMasterDocxZip(this.queryForm));
                    }
                }
            } else {
                window.open(
                    exportManageList(
                        this.selectStudents.length > 0
                            ? {
                                  ids: this.selectStudents
                                      .map(s => s.id)
                                      .join(",")
                              }
                            : this.queryForm
                    )
                );
            }
        },
        handleSelectionChange(val) {
            // console.log(val, 'val');

            this.selectStudents = val;
        },
        //预览组内用户信息
        handleReviewGroup(groupId) {
            this.$refs.groupUsers.open();
            this.usersQueryForm.groupId = groupId;
            this.getGroupUsersByGroupId();
        },
        //关闭组内用户信息时初始化
        handleGroupUsersClose() {
            this.usersQueryForm.groupId = null;
            this.usersQueryForm.pageNum_ = 1;
            this.usersQueryForm.pageSize_ = 20;
            this.usersQueryForm.total_ = 0;
        },
        //组内用户信息翻页
        handleUserCurrentChange(val) {
            this.usersQueryForm.pageSize_ = val.pageSize;
            this.usersQueryForm.pageNum_ = val.pageNum;
            this.getGroupUsersByGroupId();
        },
        //获取组内用户列表
        getGroupUsersByGroupId(groupId) {
            getUserInfoListByGroupId({
                groupId: this.usersQueryForm.groupId,
                pageNum_: this.usersQueryForm.pageNum_,
                pageSize_: this.usersQueryForm.pageSize_,
                total: 0,
                userName: ""
            }).then(res => {
                if (res.code == 200) {
                    this.users = res.data.list;
                    this.usersQueryForm.total_ = res.data.total_;
                }
            });
        },
        moment(val) {
            return moment(val).format("YYYY-MM-DD HH:mm:ss");
        },
        getFileName(path) {
            if (path.indexOf("/") != -1) {
                return path.substring(path.lastIndexOf("/") + 1);
            } else {
                return path;
            }
        },
        getApproveText(scope) {
            let option = this.options.approvalStatus.find(
                s => s.value == scope.row.approvalStatus
            );
            return option ? option.label : null;
        },
        getUserType(val) {
            if (val == 1) {
                return "老师";
            }
            if (val == 2) {
                return "学生";
            }
            if (val == 3) {
                return "本地用户";
            }
            return null;
        },
        //验证批量请示文号
        validateBatchPleaseNum(rule, value, callback) {
            if (!this.isBatchReject) {
                if (
                    _.isNull(this.batchForm.pleaseNum) ||
                    _.trim(this.batchForm.pleaseNum) == ""
                ) {
                    callback(new Error("必须输入请示文号"));
                    return;
                }
            }
            callback();
        },
        //验证批量发文编号
        validateBatchIssueNum(rule, value, callback) {
            if (!this.isBatchReject) {
                if (
                    _.isNull(this.batchForm.issueNum) ||
                    _.trim(this.batchForm.issueNum) == ""
                ) {
                    callback(new Error("必须输入发文编号"));
                    return;
                }
            }
            callback();
        },
        //验证批量审批意见
        validateBatchSuggestion(rule, value, callback) {
            if (this.isBatchReject) {
                if (
                    _.isNull(this.batchForm.suggestion) ||
                    _.trim(this.batchForm.suggestion) == ""
                ) {
                    callback(new Error("必须输入审批意见"));
                    return;
                }
            }
            callback();
        },
        //验证表单审核建议
        validateSuggestion(rule, value, callback) {
            if (this.isReject) {
                if (
                    _.isNull(this.submitForm.suggestion) ||
                    _.trim(this.submitForm.suggestion) == ""
                ) {
                    callback(new Error("必须输入审批意见"));
                    return;
                }
            }
            callback();
        },
        //验证表单请示文号
        validatePleaseNum(rule, value, callback) {
            if (!this.isReject) {
                if (
                    _.isNull(this.submitForm.pleaseNum) ||
                    _.trim(this.submitForm.pleaseNum) == ""
                ) {
                    callback(new Error("必须输入请示文号"));
                    return;
                }
            }
            callback();
        },
        //验证表单发文编号
        validateIssueNum(rule, value, callback) {
            if (!this.isReject) {
                if (
                    _.isNull(this.submitForm.issueNum) ||
                    _.trim(this.submitForm.issueNum) == ""
                ) {
                    callback(new Error("必须输入发文编号"));
                    return;
                }
            }
            callback();
        }
    },
    watch: {
        currentApproveStatus: {
            handler(newVal) {
                // 学院审核5必填，留办审核非必填--请示文号
                // 学校审核（培养处7）非必填，学校审核（管理处8）必填--发文编号
                if (newVal === '5') {
                    this.submitRules.pleaseNum.required = true;
                } else if (newVal === '8') {
                    this.submitRules.issueNum.required = true;
                } else {
                    this.submitRules.pleaseNum.required = false;
                    this.submitRules.issueNum.required = false;
                }
            },
            deep: true,
            immediate: true
        }
    }
};
</script>

<style lang="scss" scoped>
.table-detail {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #d2d4d6;
    td {
        border-collapse: collapse;
        border: 1px solid #d2d4d6;
        line-height: 32px;
    }
    .label {
        text-align: right;
        background: #f5f7f9;
        color: #8896a7;
    }
    span {
        margin: 0 10px;
    }
}
#batch-dialog {
    ::v-deep .edu-dialog_body {
        padding-bottom: 10px;
    }
}
.waring-msg {
    p {
        color: red;
        margin: 0;
        margin-left: 150px;
    }
    p:last-child {
        text-indent: 55px;
    }
}
</style>
